<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page contentType="text/html;charset=UTF-8" %>
<%@ page import="com.lmpop.trade.ts_category.*" %>
<%@ page import="com.lmpop.trade.ti_normal_biz.*" %>
<%@ page import="com.lmpop.trade.tb_commpara.Tb_commparaInfo" %>
<%@ page import="com.lmpop.trade.ts_categoryattr.*" %>
<%@page import="com.lmpop.trade.ti_company.*" %>
<%@ page import="java.util.*" %>
<%@ page import="com.lmpop.trade.ti_payment.*" %>
<jsp:useBean id="randomId" class="com.lmpop.frame.util.RandomID" scope="page" />  
<% 
  	String biz_id="";
  	if(request.getParameter("biz_id")!=null) biz_id = request.getParameter("biz_id");

  	Ti_normal_bizInfo ti_normal_bizInfo = new Ti_normal_bizInfo();
	Tb_commparaInfo tb_commparaInfo = new Tb_commparaInfo(); 
	Ts_categoryInfo ts_categoryInfo = new Ts_categoryInfo();
	Map catMap = ts_categoryInfo.getCatClassMap("10");
	Ti_paymentInfo payment = new Ti_paymentInfo();
  	List list = ti_normal_bizInfo.getListByPk(biz_id);
	
  	Hashtable map = new Hashtable();
  	if(list!=null && list.size()>0) map = (Hashtable)list.get(0);
	String cust_id="",to_cust_id="",publish_user_id="",cust_class="";;
	if(request.getParameter("cust_id")!=null && !request.getParameter("cust_id").equals("")){
		cust_id = request.getParameter("cust_id");
	}
	if(request.getParameter("to_cust_id")!=null && !request.getParameter("to_cust_id").equals("")){
		to_cust_id = request.getParameter("to_cust_id");
	}
	if(session.getAttribute("session_user_id")!=null){
		publish_user_id  = session.getAttribute("session_user_id").toString();
	}                     
	String s_title = "";
	if(request.getParameter("s_title")!=null && !request.getParameter("s_title").equals("")){
		s_title = request.getParameter("s_title");
	}
	String state_c = "";
	if(request.getParameter("state_c")!=null && !request.getParameter("state_c").equals("")){
		state_c = request.getParameter("state_c");
	}
	String info_state = "";
	if(request.getParameter("info_state")!=null && !request.getParameter("info_state").equals("")){
		info_state = request.getParameter("info_state");
	}
	String type = "";
	if(request.getParameter("type")!=null && !request.getParameter("type").equals("")){
		type = request.getParameter("type");
	}
	String area_attr="";
	
	Ti_companyInfo ti_companyInfo = new Ti_companyInfo();
  List custlist = ti_companyInfo.getListByPk(to_cust_id);
  Hashtable custmap = new Hashtable();
  if(custlist!=null && custlist.size()>0) custmap = (Hashtable)custlist.get(0);
	if(custmap.get("area_attr")!=null) area_attr = custmap.get("area_attr").toString();
	
	
	String iStart = "0";
	if(request.getParameter("iStart")!=null) iStart = request.getParameter("iStart");	
	 
	String para = "/program/admin/unionsale/brandbizindex.jsp?cust_id="+cust_id;		 
  	
  	String biz_type="",title="",content="",biz_price="",currency="",end_date="",pack_type="",attr_desc="",mini_supply="",max_supply="",market_type="",units="",transaction_mode="",delivery_date="",
		   logistics="",wholesale="",product_spec="",certify_req="",class_attr="",remark="",sale_spec="",qua_date="",rep_date="",payments="";

		if(map.get("biz_type")!=null) biz_type = map.get("biz_type").toString();
		if(map.get("title")!=null) title = map.get("title").toString();
		if(map.get("content")!=null) content = map.get("content").toString();
		if(map.get("biz_price")!=null) biz_price = map.get("biz_price").toString();
		if(map.get("currency")!=null) currency = map.get("currency").toString();
		if(map.get("end_date")!=null) end_date = map.get("end_date").toString();
		if(map.get("pack_type")!=null) pack_type = map.get("pack_type").toString();
		if(map.get("mini_supply")!=null) mini_supply = map.get("mini_supply").toString();
		if(map.get("max_supply")!=null) max_supply = map.get("max_supply").toString();
		if(map.get("market_type")!=null) market_type = map.get("market_type").toString();
		if(map.get("units")!=null) units = map.get("units").toString();
		if(map.get("transaction_mode")!=null) transaction_mode = map.get("transaction_mode").toString();
		if(map.get("delivery_date")!=null) delivery_date = map.get("delivery_date").toString();
		if(map.get("logistics")!=null) logistics = map.get("logistics").toString();
		if(map.get("wholesale")!=null) wholesale = map.get("wholesale").toString();
		if(map.get("product_spec")!=null) product_spec = map.get("product_spec").toString();
		if(map.get("certify_req")!=null) certify_req = map.get("certify_req").toString();
		if(map.get("class_attr")!=null) class_attr = map.get("class_attr").toString();
		
		if(map.get("remark")!=null) remark = map.get("remark").toString();
		if(map.get("attr_desc")!=null) attr_desc = map.get("attr_desc").toString();
		 
		
		if(map.get("sale_spec")!=null) sale_spec = map.get("sale_spec").toString();
		if(map.get("qua_date")!=null) qua_date = map.get("qua_date").toString();
		if(map.get("rep_date")!=null) rep_date = map.get("rep_date").toString();
		if(map.get("payments")!=null) payments = map.get("payments").toString();
	
	 
	String currency_name = tb_commparaInfo.getSelectItem("36",currency);
 
	if (request.getParameter("class_attr") != null){
		class_attr = request.getParameter("class_attr");
	}
	String catAttr[] = class_attr.split("\\|");
	String cat_names ="";  
	if(!class_attr.equals("")){
	  String catIds[] =	class_attr.split("\\|");	
	  for(String catId:catIds){
		 if(catMap!=null){
			 if(catMap.get(catId)!=null){
			  cat_names += catMap.get(catId).toString() + " > ";                 
			 }                  
		 }                 
	  }		    
	}
	Ts_categoryattrInfo ts_categoryattrInfo = new Ts_categoryattrInfo();
	List attList = new ArrayList();
	if(!catAttr[catAttr.length-1].equals("")){
		attList = ts_categoryattrInfo.getListByClassId(catAttr[catAttr.length-1]);
	}  

	List attrValueList = new ArrayList();
	int attrsize = 0,valuesize = 0;
	 
	
	if( session.getAttribute("session_cust_class") != null ){
		cust_class = session.getAttribute("session_cust_class").toString();
	}	
	List paymentlist = payment.getCustPayment("100000000000000");
	
	String new_biz_id = randomId.GenTradeId();
%>
<html>
  <head>   
    <title>拷贝发布联合商务信息</title>
	<script type="text/javascript" src="biz.js"></script>
	<link href="/program/company/index/css/style.css" rel="stylesheet" type="text/css">
	<script type="text/javascript"> 
var record={ 
num:"" 
} 
var checkDecimal=function(n){ 
var decimalReg=/^\d{0,8}\.{0,1}(\d{1,2})?$/;//var decimalReg=/^[-\+]?\d{0,8}\.{0,1}(\d{1,2})?$/; 
if(n.value!=""&&decimalReg.test(n.value)){ 
record.num=n.value; 
}else{ 
if(n.value!=""){ 
n.value=record.num; 
} 
} 
} 
</script> 
</head>

<body>

	<h1>发布大品牌联合商务信息到分公司</h1>
	
	<form action="/doTradeReg.do" method="post" name="addForm">
		<table width="100%" cellpadding="1" cellspacing="1" border="0" class="listtabadd">
			<tr>
				<td colspan="4">
			   &nbsp;&nbsp;<img src="/program/admin/images/infotip.gif" border="0">&nbsp;&nbsp;<span style="font-size:14px;font-weight:bold;">基本信息</span>			</td>
		    </tr>
			
			<tr>
			<td class="labletd" width="20%">
				你选择的类目:			
			</td>
			<td  colspan="3">
			   <font color="red"><%=cat_names%></font> 
				  
			</td>
		</tr>
		
		<tr>
			<td class="labletd" width="20%">
				  产品属性:				
			</td>
			<td colspan="3">
			   <span class="STYLE5" style="color:#FF7300;">产品属性填写的越少，越容易流失被搜索到的机会！建议您尽可能完整填写！</span> <br/>

			 <%
				if( attList != null && attList.size() > 0 ) {
				 attrsize = attList.size();
				 Hashtable attrmap = new Hashtable();
				 for( int i = 0; i < attrsize; i++ ){
					 attrmap = ( Hashtable )attList.get(i);
					 String attr_id = "",attr_name = "",default_tag ="", con_type="",attrStr = "",isfill="";
					 if( attrmap.get("attr_id") != null ) {
						 attr_id = attrmap.get("attr_id").toString();
					 }
					 if( attrmap.get("attr_name") != null ) {
						 attr_name = attrmap.get("attr_name").toString();
					 }
					 if( attrmap.get("default_tag") != null ) { // if fill in or not									 
						 default_tag = attrmap.get("default_tag").toString();
					 }
					 if( attrmap.get("con_type") != null ){
						 con_type = attrmap.get("con_type").toString();
					 }
					 if( default_tag.equals("0")){
						 isfill = " <span style='color:red;'>*</span>";
					 }	 
			%>
				
		<table width="100%" border="0" cellspacing="0" cellpadding="0">
			<tr>
			  <td width="18%" height="35" align="right" style="background:#F9F9F9;">
				 &nbsp;<%=attr_name%><%=isfill%>
			  </td>
			  <td width="48%" style="background:#F9F9F9;">			  
				  <input type="hidden" name="attr_id<%=i%>" id="attr_id<%=i%>" value="<%=attr_id%>" /> 
				  <input type="hidden" name="attr_name<%=i%>" id="attr_name<%=i%>" value="<%=attr_name%>" />
				  <input type="hidden" name="con_type<%=i%>" id="con_type<%=i%>" value="<%=con_type%>" />
				  <input type="hidden" name="default_tag<%=i%>" id="default_tag<%=i%>" value="<%=default_tag%>" />
				<%
						String attrValue = "";		
						if(con_type.equals("0")){
							 attrValue = ts_categoryattrInfo.getSelectItems(attr_id,attr_desc);									
				%>	
						   <select class="input" name="attr_value<%=i%>" id="attr_value<%=i%>" style="height:20px;">
								<option value="">请选择</option>
								<%=attrValue%>
						   </select>
				<%			
						}
							
						if( con_type.equals( "1") ){  
							attrValue= ts_categoryattrInfo.getInputItems(attr_id,attr_desc);												 
				%>
							<input class="input" maxlength="30" type="text" name="attr_value<%=i%>" id="attr_value<%=i%>"   size="20" maxlength="100" value="<%=attrValue%>" />
				<%			
						}
						if( con_type.equals( "2") ){
							attrValueList = ts_categoryattrInfo.getListByPk(attr_id);
							attrValue = ts_categoryattrInfo.getCheckboxItems(attr_id,attr_desc);
							if( attrValueList != null && attrValueList.size() > 0 ) {
								Hashtable valuemap = (Hashtable)attrValueList.get(0);
								String default_value="";                           
								if( valuemap.get("default_value") != null ){
									 default_value = valuemap.get("default_value").toString();
								}
								String attrValues[] = default_value.split("\\|");												  
							    valuesize = attrValues.length;
							    for( int j = 0; j < valuesize; j++ ) {
					 %>
								<input class="input" type="checkbox" name="attr_value<%=i%>" id="attr_value<%=i%>_<%=j%>" value="<%=attrValues[j]%>"  <%if(attrValue.indexOf(attrValues[j])>-1)out.print("checked");%>/><%=attrValues[j]%>	
																	
					 <%	   
								}
					 %>
						  <input type="hidden" name="valuesize<%=i%>" id="valuesize<%=i%>" value="<%=valuesize%>" /> 
					<%
						}
					}
					%>		
				
				<span class="STYLE5"></span>
			  </td>
			  <td width="36%"></td>
			</tr>
		  </table>
				<%		
						}
					 }
				%>
				
			<input type="hidden" name="attrsize" id="attrsize" value="<%=attrsize%>" />
		</td>
       </tr>
	     
      

		<tr>
			<td class="labletd" width="20%">
				 信息标题<font color="red">*</font>
			</td>
			<td colspan="3">
				  <input type="text" name="title" id="title" size="62" maxlength="100" value="<%=title%>" />
			 </td>
		</tr>

		<tr>
			<td class="labletd" width="20%">
				产品图片:			
			</td>
			<td colspan="3">
			<jsp:include page="/program/inc/uploadImgInc.jsp">
					<jsp:param name="attach_root_id" value="<%=new_biz_id%>" />
					<jsp:param name="old_attach_root_id" value="<%=biz_id%>" />
					<jsp:param name="img_type" value="1" />
					<jsp:param name="req_type" value="sale" />
				</jsp:include><span style="color:red">请重新上传图片</span>
			</td>
		</tr> 

		<tr>
			<td class="labletd" width="20%">
				详细说明<font color="red">*</font>					
			</td>
			<td colspan="3">
			  <textarea name="content"><%=content%></textarea>
			<script type="text/javascript" src="/program/plugins/ckeditor/ckeditor.js"></script>
			<script type="text/javascript">
				 //CKEDITOR.replace('content');
			   CKEDITOR.replace( 'content',{
			   	     filebrowserUploadUrl : '/program/inc/upload.jsp?type=file&attach_root_id=<%=new_biz_id%>',      
                filebrowserImageUploadUrl : '/program/inc/upload.jsp?type=img&attach_root_id=<%=new_biz_id%>',      
                filebrowserFlashUploadUrl : '/program/inc/upload.jsp?type=flash&attach_root_id=<%=new_biz_id%>'     
            });  
			</script>
			
			</td>
	</tr>      
    
	<tr>
		<td  colspan="4">
	   &nbsp;&nbsp;<img src="/program/admin/images/infotip.gif" border="0">&nbsp;&nbsp;<span style="font-size:14px;font-weight:bold;">交易信息</span>			
		</td>
	</tr>


	<tr style="display:none">
	  <td class="labletd" width="20%">商品价格<font color="red">*</font></td>	   
	  <td width="28%">
		 <input type="text" name="biz_price" id="biz_price" size="30" maxlength="15" onkeyup='checkDecimal(this)' value="0"/>
	  </td>
	  <td width="12%" class="labletd">币种:</td>
	  <td width="50%">
		 <select name="currency" id="currency">
			<option value="">请选择</option>
			<%=currency_name%>
		 </select>			  
	  </td>
	</tr>

	<tr>
	  <td class="labletd" width="20%">混批控制量<font color="red">*</font></td>	   
	  <td width="28%">
		 <input type="text" name="mini_supply" id="mini_supply" size="30" maxlength="50"  onKeyUp="if(isNaN(value))this.value=''" />（混批控制量为0时，不限制混批数量）
	  </td>
	  <td width="12%" class="labletd">商品总量<font color="red">*</font></td>
	  <td width="50%">
		<input name="max_supply" id="max_supply" type="text" maxlength="50" size="30"  onKeyUp="if(isNaN(value))this.value=''" />
	  </td>
	</tr>
    
    
	<tr>
	  <td class="labletd" width="20%">订货计量单位:</td>	   
	  <td width="28%">
		 <input type="text" name="units" id="units" size="30" value="<%=units%>" maxlength="50" />（如：吨、件、包、公斤等）
	  </td>
	  <td width="12%" class="labletd">行销方式:</td>
	  <td width="50%">
		<input name="market_type" id="market_type" type="text" value="<%=market_type%>" maxlength="50" size="30"  />
	  </td>
	</tr>
    
	<tr>
	 <td class="labletd" width="20%">成交方式:</td>	   
	  <td width="28%">
		 <input type="text" name="transaction_mode" id="transaction_mode" value="<%=transaction_mode%>" size="30" maxlength="50" />
	  </td>
	  <td width="12%" class="labletd">交货期:</td>
	  <td width="50%">
		 <input name="delivery_date" id="delivery_date" type="text" value="<%=delivery_date%>" maxlength="50" size="30" />
	  </td>
	</tr>
    
    
	<tr>
	 <td class="labletd" width="20%">货物始发地:</td>	   
	  <td width="28%">
		 <input type="text" name="logistics" id="logistics"size="30" maxlength="50" />	     
	  </td>
	  <td width="12%" class="labletd">经销批发:</td>
	  <td width="50%">
		<input type="text" name="wholesale" id="wholesale" value="<%=wholesale%>" size="30" maxlength="50" />          			 
	  </td>
	  </tr>
    
    
     <tr>
		 <td class="labletd" width="20%">货物产地:</td>	   
		  <td width="28%">
			 <input type="text" name="product_spec" id="product_spec" value="<%=product_spec%>" size="30" maxlength="50" />
		  </td>
		  <td width="12%" class="labletd">产品认证:</td>
		  <td width="50%">
			<input name="certify_req" id="certify_req" type="text" value="<%=certify_req%>" maxlength="50" size="30" />
		  </td>
	  </tr>

		<tr>
		 <td class="labletd" width="20%">产品规格:</td>	   
		  <td width="28%">
			 <input type="text" name="sale_spec" id="sale_spec" size="30" maxlength="50"  value="<%=sale_spec%>"/>
		  </td>
		  <td width="12%" class="labletd">保质期:</td>
		  <td width="50%">
			<input name="qua_date" id="qua_date" type="text" maxlength="50" size="30"  value="<%=qua_date%>"/>
		  </td>
	  </tr>
	  
	  <tr>
		 <td class="labletd" width="20%">保修期:</td>	   
		  <td width="28%">
			 <input type="text" name="rep_date" id="rep_date" size="30" maxlength="50"  value="<%=rep_date%>"/>
		  </td>
		  <td width="12%" class="labletd">支付方式:</td>
		  <td width="50%">
		  <%
		  	String pay_name="",pay_id="";
		  	int paylistsize = 0;
		  	if (paymentlist!=null && paymentlist.size()>0)
		  	{
		  		paylistsize = paymentlist.size();
		  		for (int i = 0; i < paymentlist.size(); i++) 
		  		{
						Hashtable objMap = (Hashtable) paymentlist.get(i);
						if (objMap.get("pay_id") != null) pay_id = objMap.get("pay_id").toString();
						if (objMap.get("pay_name") != null) pay_name = objMap.get("pay_name").toString();
						 
						if(!payments.equals(""))
						{
							if (payments.indexOf(pay_id)>=0)
							{
						%>
									<input type="checkbox" name="payment<%=i%>" id="payment<%=i%>" value="<%=pay_id%>" checked="true"/><%=pay_name%> 
						<%							
							}
							else
							{
						%>
							<input type="checkbox" name="payment<%=i%>" id="payment<%=i%>" value="<%=pay_id%>" /><%=pay_name%> 
						<%
							}
		  			}
		  		else
		  			{
		  			%>
							<input type="checkbox" name="payment<%=i%>" id="payment<%=i%>" value="<%=pay_id%>" /><%=pay_name%> 
						<%
		  			}
		  		}
		  	}
		  %>
			 
		  </td>
	  </tr>

	<tr>
		<td  colspan="4">
	   &nbsp;&nbsp;<img src="/program/admin/images/infotip.gif" border="0">&nbsp;&nbsp;<span style="font-size:14px;font-weight:bold;">其他信息</span>			
		</td>
	</tr>
	
	<tr>
		<td class="labletd" width="20%">
			信息有效期<font color="red">*</font>			
		</td>
		<td colspan="3">    
			<input type="radio" name="end_date" id="end_date1" value="10"  <%if(end_date.equals("10")){ %>checked<%}%> />10天
			<input type="radio" name="end_date" id="end_date2" value="20"  <%if(end_date.equals("20")){ %>checked<%}%> />20天
			<input type="radio" name="end_date" id="end_date3" value="30"  <%if(end_date.equals("30")){ %>checked<%}%> />1个月	
			<input type="radio" name="end_date" id="end_date4" value="90"  <%if(end_date.equals("90")){ %>checked<%}%> />3个月	
			<input type="radio" name="end_date" id="end_date5" value="180" <%if(end_date.equals("180")){%>checked<%}%> />6个月
			<input type="radio" name="end_date" id="end_date6" value="365" <%if(end_date.equals("365")){%>checked<%}%> />一年
			<input type="radio" name="end_date" id="end_date7" value="730" <%if(end_date.equals("730")){%>checked<%}%> />两年
			<input type="radio" name="end_date" id="end_date8" value="1095" <%if(end_date.equals("1095")){%>checked<%}%> />三年
			<input type="radio" name="end_date" id="end_date9" value="36500" <%if(end_date.equals("36500")){%>checked<%}%> />永久
		</td>
	</tr>

    	
	</table>
	 	
	<table width="100%" cellpadding="0" cellspacing="0" border="0">
		<tr>
			<td align="center">
				<input type="hidden" name="bpm_id" value="3784" />
				<input type="button" class="buttoncss" name="tradeSub" value="提交" onclick="subForm()"/>&nbsp;&nbsp;
				<input type="button" class="buttoncss" name="tradeRut" value="返回" onclick="window.location.href='<%=para%>';"/>
			</td>
		</tr>
	</table>
	
	<input type="hidden" name="cust_id" id="cust_id" value="<%=to_cust_id%>" />
	<input type="hidden" name="user_id" id="user_id" value="<%=publish_user_id%>" />
	<input type="hidden" name="state_code" id="state_code" value="c" />
	<input type="hidden" name="rsrv_str4" id="rsrv_str4" value="<%=cust_id%>" />
	<input type="hidden" name="biz_type" id="biz_type" value="f" />
	<input type="hidden" name="area_attr" value="<%=area_attr%>" />
	<input type="hidden" name="rsrv_str6" id="rsrv_str6" value="1" />
	<input type="hidden" name="rsrv_str3" id="rsrv_str3" value="<%=biz_id%>" />
	<input type="hidden" name="biz_id" id="biz_id" value="<%=new_biz_id%>" />
	<input type="hidden" name="class_attr" id="class_attr" value="<%=class_attr%>" />
	<input type="hidden" name="state_flag" id="state_flag" value="" />
	<input type="hidden" name="attr_desc" id="attr_desc" value="" />
	
 
	<input type="hidden" name="paylistsize" id="paylistsize" value="<%=paylistsize %>" />
	 <input type="hidden" name="payid" id="payid" value="" />
	</form>
	
</body>

</html>
